<?
require_once('./lib/lib.gear.php');
/*
$url = 'http://api.mixi-platform.com/2/voice/statuses';

$data = array(
    'status' => 'test でーす',
);
*/

$url = 'http://api.mixi-platform.com/2/messages/@me/@self/@outbox';


//$data = array(
//    '{"title" : "件名","body" : "本文","recipients" : ["yee7djy9m7i6k"]}',
//);


$data = '{"title" : "たいとる" after english","body" : "こんにちは2\nあああ","recipients" : ["yee7djy9m7i6k"]}';

$headers = array(
	"Content-Type: application/json; charset=UTF-8",
	"Content-Length: 127",
    "Authorization: OAuth f5d44d7b233a1b40cf09f8274d89f96ad980aca2\r\n",
);

$options = array('http' => array(
    'method' => 'POST',
    'content' => $data,
    'header' => implode("\r\n", $headers),
));

$contents = file_get_contents($url, false, stream_context_create($options));


preDump(http_build_query($data));
preDump(implode("\r\n", $headers));
preDump($contents);

/**************************************************************************/
/*
$longUrl = "http://api.mixi-platform.com/2/messages/@me/@self/@outbox";
$curl = curl_init();
$curl_params = array(

    // ヘッダをapplication/jsonに
    CURLOPT_HTTPHEADER => array(
    							"Content-Type: application/json",
								"Content-Length: 127",
							    "Authorization: OAuth 423d4a91b80ddf12e424d44563c0889e61a93c46",
    							),
    // POSTで送ります
    CURLOPT_POST => true,
    // ロングURLの情報をJSONに加工して渡します
    CURLOPT_POSTFIELDS => json_encode( array( "title"        => 'aaaあああ',
    											"body"       => "honbunnののの",
    											"recipients" => '["yee7djy9m7i6k"]'
    											) ),
    CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array( $curl, $curl_params );
$result = json_decode( curl_exec( $curl ) ); // 返り値はJSONなのでデコード
var_dump( $result );
*/

?>